package com.itheima.app.controller;

import com.itheima.app.manager.SlideCardsManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * 探花-左滑右滑，是否已经喜欢
 *
 * @author DogeGuo
 */
@RestController
public class SlideCardsController {
    @Autowired
    SlideCardsManager slideCardsManager;

    /**
     * 查询推荐用户
     *
     * @return
     */
    @GetMapping("/tanhua/cards")
    public ResponseEntity slideCards() {
        // 调用manager
        return slideCardsManager.slideCards();
    }

    /**
     * 右划喜欢，并判断对方是否喜欢自己
     *
     * @param likeUserId
     */
    @GetMapping("/tanhua/{likeUserId}/love")
    public void saveLove(@PathVariable Long likeUserId) {
        // 调用manager
        slideCardsManager.saveLove(likeUserId);
    }

    /**
     * 左划不喜欢
     *
     * @param likeUserId
     */
    @GetMapping("/tanhua/{likeUserId}/unlove")
    public void removeLove(@PathVariable Long likeUserId) {
        // 调用manager
        slideCardsManager.removeLove(likeUserId);
    }

    /**
     * 是否喜欢（新增接口）
     *
     * @param likeUserId
     * @return
     */
    @GetMapping("/users/{likeUserId}/alreadyLove")
    public ResponseEntity findAlreadyLove(@PathVariable Long likeUserId) {
        return slideCardsManager.findAlreadyLove(likeUserId);
    }
}
